package com.huo.task.service;

import com.huo.common.enumtype.FileTypeEnum;
import com.huo.filestransport.service.FtpService;
import com.huo.filestransport.vo.FtpServerInfo;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

@DisallowConcurrentExecution
public class UploadFileByDB implements Job {

	private final Logger logger = LoggerFactory.getLogger(getClass());
	@Autowired
	private FtpService transportService;
	@Autowired
	private FtpServerInfo ftpServerInfo;
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		logger.info("上传队列中文件的JOB开始：" );
		transportService.uploadFileByDB(transportService.makeFtpDirectory(FileTypeEnum.UPLOAD),
				ftpServerInfo.getLocalDirectory(), transportService.makeFtpDirectory(FileTypeEnum.DOWNLOAD));
		logger.info("上传队列中文件的JOB结束：" );
	}

}
